import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;


public class SemanticAnalyzer {
public void html() throws FileNotFoundException {
		
		// Makes output.html file of the HTML code
		PrintStream out = new PrintStream(new FileOutputStream("output.html"));
		
		// Converts every annotation into HTML code
		while (!MySyntaxAnalyzer.syntaxList.isEmpty()){
			String tag = MySyntaxAnalyzer.syntaxList.get(0);
			if (tag.equalsIgnoreCase("#START DOCUMENT")){
				out.println("<html>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END DOCUMENT")){
				out.println("</html>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START HEAD")){
				out.println("<head>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END HEAD")){
				out.println("</head>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START TITLE")){
				out.println("<title> ");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END TITLE")){
				out.print(" </title>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START PARAGRAPH")){
				out.println("<p>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END PARAGRAPH")){
				out.print("</p>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START BOLD")){
				out.println("<b>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END BOLD")){
				out.print("</b>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START ITALICS")){
				out.println("<i>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END ITALICS")){
				out.print("</i>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START LIST")){
				out.println("<ul>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END LIST")){
				out.print("</ul>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START LIST")){
				out.println("<li>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END LIST")){
				out.print("</li>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#NEWLINE")){
				out.print("<br>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START AUDIO")){
				out.println("<audio controls>");
				out.print("<source src=");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END AUDIO")){
				out.print(">");
				out.print("</audio>");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#START VIDEO")){
				out.println("<iframe src='");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else if (tag.equalsIgnoreCase("#END VIDEO")){
				out.print("/>'");
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
			else { 
				out.print(tag);
				MySyntaxAnalyzer.syntaxList.remove(0);
			}
		}
	}
	
}
